#include "mainwindow.h"
#include "dsingleapplication.h"
#include <QtGui>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setQuitOnLastWindowClosed(false);

    QString locale = QLocale::system().name();

    QTranslator translator;
    if(translator.load(QString(":/Languages/SerialTemper_") + locale)) a.installTranslator(&translator);

    MainWindow w;

    DSingleApplication instance( "SerialTemper" );
    QObject::connect( &instance, SIGNAL( messageReceived(const QString &) ),
                     &w,   SLOT( onOtherInstanceMessage(const QString &) ) );
    if ( instance.isRunning() ) {
       instance.sendMessage( "Hey, i'm the other instance" );
       return 0;
    }

    if(!w.hasMinimizedStartup()) w.show();

    return a.exec();
}
